package com.serkol.ams.module.sys.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * 
 * @TableName sys_users
 */
@TableName(value ="sys_users")
@Data
public class SysUsers implements Serializable, UserDetails {
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 
     */
    private String nickname;

    /**
     * 
     */
    private String avatar;

    /**
     * 
     */
    private String unionid;

    /**
     * 
     */
    private String openid;

    /**
     * 
     */
    private String phone;

    /**
     * 
     */
    private String username;

    /**
     * 
     */
    private String password;

    /**
     * 
     */
    private Long createDate;

    /**
     * 
     */
    private Long updateDate;

    /**
     * 
     */
    private Long agentId;

    /**
     * 
     */
    private Long parentUserId;

    /**
     * 
     */
    private String invite;

    /**
     * 
     */
    private Integer agentState;

    /**
     * 
     */
    private Integer status;

    /**
     * 
     */
    private Integer deleted;

    /**
     * 
     */
    private Integer isAdmin;

    /**
     * 
     */
    private Long roleId;


    /**
     *
     */
    private boolean isAccountNonExpired;

    /**
     *
     */
    private boolean isAccountNonLocked;

    /**
     *
     */
    private boolean isCredentialsNonExpired;

    /**
     *
     */
    private boolean isEnabled;

        @TableField(exist = false)
    private List<GrantedAuthority> authorities;

    /**
     * 查询用户权限表
     *
     * @return
     */
    @TableField(exist = false)
    private List<SysMenu> permissionList;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SysUsers sysUsers = (SysUsers) o;
        return isAccountNonExpired == sysUsers.isAccountNonExpired && isAccountNonLocked == sysUsers.isAccountNonLocked && isCredentialsNonExpired == sysUsers.isCredentialsNonExpired && isEnabled == sysUsers.isEnabled && Objects.equals(id, sysUsers.id) && Objects.equals(nickname, sysUsers.nickname) && Objects.equals(avatar, sysUsers.avatar) && Objects.equals(unionid, sysUsers.unionid) && Objects.equals(openid, sysUsers.openid) && Objects.equals(phone, sysUsers.phone) && Objects.equals(username, sysUsers.username) && Objects.equals(password, sysUsers.password) && Objects.equals(createDate, sysUsers.createDate) && Objects.equals(updateDate, sysUsers.updateDate) && Objects.equals(agentId, sysUsers.agentId) && Objects.equals(parentUserId, sysUsers.parentUserId) && Objects.equals(invite, sysUsers.invite) && Objects.equals(agentState, sysUsers.agentState) && Objects.equals(status, sysUsers.status) && Objects.equals(deleted, sysUsers.deleted) && Objects.equals(isAdmin, sysUsers.isAdmin) && Objects.equals(roleId, sysUsers.roleId) && Objects.equals(authorities, sysUsers.authorities) && Objects.equals(permissionList, sysUsers.permissionList);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, nickname, avatar, unionid, openid, phone, username, password, createDate, updateDate, agentId, parentUserId, invite, agentState, status, deleted, isAdmin, roleId, isAccountNonExpired, isAccountNonLocked, isCredentialsNonExpired, isEnabled, authorities, permissionList);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", nickname=").append(nickname);
        sb.append(", avatar=").append(avatar);
        sb.append(", unionid=").append(unionid);
        sb.append(", openid=").append(openid);
        sb.append(", phone=").append(phone);
        sb.append(", username=").append(username);
        sb.append(", password=").append(password);
        sb.append(", createDate=").append(createDate);
        sb.append(", updateDate=").append(updateDate);
        sb.append(", agentId=").append(agentId);
        sb.append(", parentUserId=").append(parentUserId);
        sb.append(", invite=").append(invite);
        sb.append(", agentState=").append(agentState);
        sb.append(", status=").append(status);
        sb.append(", deleted=").append(deleted);
        sb.append(", isAdmin=").append(isAdmin);
        sb.append(", roleId=").append(roleId);
        sb.append(", isAccountNonExpired=").append(isAccountNonExpired);
        sb.append(", isAccountNonLocked=").append(isAccountNonLocked);
        sb.append(", isCredentialsNonExpired=").append(isCredentialsNonExpired);
        sb.append(", isEnabled=").append(isEnabled);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}